HTMLify
Interleave the First Half of the Queue with Second Half.py
Views: 44 | Author: prakhardoneria
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | from collections import deque class Solution: def rearrangeQueue(self, q): n = len(q) half = n // 2 temp = deque() for _ in range(half): temp.append(q.popleft()) while temp: q.append(temp.popleft()) q.append(q.popleft()) |